package com.shiyue.cqe.dao;

import java.util.List;
import java.util.Map;

/**
 * Generic / common operations for most of the repositories. 
 *  
 * @author gang.liu
 */
public interface Repository<T> {
	/**
	 * Tries to get an instance of the object 
	 * @param id the id to search for
	 * @return the requested instance, or <code>null</code> if not found
	 */
	public T get(int id);
	
	/**
	 * Adds a new instance of the object
	 * @param instance the instance to save
	 */
	public void add(T entity);
	
	/**
	 * Deletes the object
	 * @param instance the object to delete
	 */
	public void remove(T entity);
	
	/**
	 * Updates the information of an existing object
	 * @param instance the instance to update
	 */
	public void update(T entity);
	
	public int excuteSQL(String sql,Object ... objs);
	
	@SuppressWarnings("unchecked")
	public List<Map> querySQL(String sql,Object ... objs);
}
